import time
from A3mall.Page.Page import Page
from selenium.webdriver.common.by import By
class Page2(Page):
    # 点击首页
    home_loc = (By.XPATH, '//*[@id="searchForm"]/div[1]/input')
    # 点击输入框输入：音乐耳机
    sreach_loc = (By.CLASS_NAME, 'search-input')
    sreachbtn_loc = (By.CLASS_NAME, 'search-input-btn')
    # 点击商品详情
    shop_loc = (By.XPATH, '/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img')
    # 点击加入购物车
    add_loc=(By.XPATH,'//a[@id="add-cart" and @class="shop-btn"]')
    # 点击购物车
    shopping_loc=(By.XPATH,'/html/body/div[3]/div[3]/div[2]/a')
    # 勾选商品
    agree_loc = (By.XPATH, '//*[@id="cart-box"]/div[1]/table/tbody/tr[2]/td[1]/input')
    # 点击结算
    js_loc=(By.CLASS_NAME,'ask-btn')
    # 点击下一步
    next_loc = (By.ID, 'order-button')

    def home(self):
        self.click(self.home_loc)
    def sreach(self):
        self.send_keys(self.sreach_loc, '音乐耳机')
    def sreachbtn(self):
        self.click(self.sreachbtn_loc)
    def shop(self):
        self.click(self.shop_loc)
    def add(self):
        self.click(self.add_loc)
    def shopping(self):
        self.click(self.shopping_loc)
    def agree(self):
        self.click(self.agree_loc)
    def js(self):
        self.click(self.js_loc)
    def next(self):
        self.click(self.next_loc)
    def a3mall_luoji3(self):
        self.a3mall_luoji1_login()
        self.home()
        self.sreach()
        self.sreachbtn()
        self.shop()
        self.add()
        self.shopping()
        self.agree()
        self.js()
        self.next()
        time.sleep(5)